home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _078054E2D90140229FCA76FD1E89661F < prev    next >
Encoding:
Text File  |  2004-01-06  |  1.4 KB  |  59 lines

  1. // ===============================================================
  2. // Vertex Program: Eye shader
  3. // Description: used in character eyes
  4. // Last Update: 15/10/2003
  5. // Coder: Tiago Sousa
  6. // ===============================================================
  7.  
  8. #include "../CGVPMacro.csi"
  9.  
  10. VertAttributes { POSITION_3 TEXCOORD0_2 NORMAL_3 }
  11.  
  12. // setup vertex components
  13. MainInput
  14. {
  15.   // common model view matrix
  16.   VIEWPROJ_MATRIX,
  17.   uniform float4   CameraPos,  
  18.   uniform float4   LightPos,
  19.   uniform float3x3 ObjToCubeSpace,
  20.   uniform float4x4 ObjMatrix
  21. }
  22.  
  23. DeclarationsScript
  24. {
  25.  
  26.   // vertex input
  27.   IN_T0_N
  28.   // vertex output
  29.   OUT_T0_T1_T2_T3_C0
  30. }
  31.  
  32. // output vertex position
  33. PositionScript = PosCommon
  34.  
  35. CoreScript
  36. {   
  37.   OUT.Tex0.xy =IN.TexCoord0.xy;
  38.   OUT.Tex1.xy =IN.TexCoord0.xy;      
  39.           
  40.   
  41.   // transform normal
  42.   float3 normalVector=IN.Normal.xyz;
  43.  
  44.   //float fLigthDist=sqrt((LightPos.xyz - vPos.xyz)*(LightPos.xyz - vPos.xyz));
  45.   
  46.   float3 eyeVector = normalize(CameraPos.xyz - vPos.xyz);
  47.   float fDot= dot(eyeVector, normalVector.xyz);  
  48.   float3 reflVector = (2*normalVector.xyz*fDot-eyeVector.xyz);  
  49.   OUT.Tex2.xyz = reflVector.xyz;
  50.   OUT.Tex3.xyz = reflVector.xyz;  
  51.   
  52.   
  53.   float3 lightVector =  normalize(LightPos.xyz-vPos.xyz);
  54.   fDot = dot(lightVector, normalVector);
  55.   OUT.Color.xyz=max(fDot, 0);
  56.   
  57.   return OUT;
  58. }
  59.